package Map;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class MapDemo1 {
    public static void main(String[] args) {
        String[] x={"A","B","C","D"};
        String[] m =new String[80];
        for (int i = 0; i <80 ; i++) {
            Random r =new Random();
            int y =r.nextInt(4);
            m[i]=x[y];
        }
        System.out.println(m.length);
        Map<String,Integer> map=new HashMap<>();
        for (String s : m) {
            if (map.containsKey(s)){//检查是否含有该键值，如果有就添加进去
                map.put(s, map.get(s)+1);//map.get(s)获得是一个数值，再加1就是一直往上加
            }
            else {
                map.put(s,1);
            }
        }
        System.out.println(map);

    }
}
